package com.xueyi.aixihu.reqeust;

import com.xueyi.aixihu.exception.SzException;
import com.xueyi.aixihu.status.SystemCode;
import lombok.Data;
import org.hibernate.validator.constraints.Length;
import org.springframework.util.StringUtils;

import javax.validation.constraints.NotNull;

/**
 * @author hxs
 * @createDate 2023/6/30 11:21
 * @description 同意通过文章审核参数
 */
@Data
public class AgreePassNewsAuditReq {


    /**
     * 审核记录id
     */
    @NotNull(message = "参数异常")
    private Integer auditId;


    /**
     * 文章id
     */
    @NotNull(message = "参数异常")
    private Integer id;

    /**
     * 操作类型 1同意 2拒绝
     */
    @NotNull(message = "参数异常")
    private Integer type;

    @Length(message = "太长了~~~", max = 255)
    private String failMsg;

    public void format() throws SzException {
        if (type.equals(2)) {
            if (!StringUtils.hasLength(failMsg)) {
                throw new SzException(SystemCode.QUERY_CHECK_ERROR, "请输入拒绝理由");
            }
        }
        failMsg = StringUtils.hasLength(failMsg) ? failMsg.trim() : failMsg;
    }


}
